using UnityEngine.UI;

public class BloodFruitTip : BasePanel
{
    //按钮
    public Button closeButton;
    public Button okButton;
    //npc
    public Npc npc;
    public override void OnClose()
    {
        base.OnClose();
        //GameManager.Instance.canOprate=true;
    }
    public override void OnInit()
    {
        base.OnInit();

        path="UI/OtherTip/BloodFruitTip";
        type=PanelType.Tip;

        GameManager.Instance.canOprate=false;
    }
    public override void OnShow(params object[] par)
    {
        base.OnShow(par);

        npc=(Npc)par[0];

        closeButton=item.transform.Find("Close").GetComponent<Button>();
        okButton=item.transform.Find("Ok").GetComponent<Button>();

        closeButton.onClick.AddListener(CloseButton);
        okButton.onClick.AddListener(OkButton);
    }
    //关闭
    public void CloseButton()
    {
        Close();
        GameManager.Instance.canOprate = true;
        AudManager.instance.PlayUIAud(AudManager.instance.uiDic["点击"], 1f);
    }
    public void OkButton()
    {
        //保存一波数据
        SaveManager.instance.SaveAllData();
        //吃下
        GameManager.Instance.eatBloodFruit=true;
        npc.gameObject.SetActive(false);
        //移除npc
        SceneItemManager.instance.SetNpcFanish(npc.npcName);
        //保存一下数据
        SceneItemManager.instance.SaveData();
        //打开死亡面板
        PanelManager.Open<DiePanel>();

        Close();
        AudManager.instance.PlayUIAud(AudManager.instance.uiDic["点击"], 1f);
    }
}
